package com.bz.cart.feign;

import com.bz.cart.feign.fallback.CommonRedisFeignClientFallbackFactory;
import com.bz.dto.CartDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 命令规范: 服务名称 + FeignClient
 */
@FeignClient(value = "common-redis",fallbackFactory = CommonRedisFeignClientFallbackFactory.class)
public interface CommonRedisFeignClient {

    //--------------------------- /redis/cart --------------------------
    @GetMapping("/redis/cart/selectCartByUserId")
    CartDto selectCartByUserId(@RequestParam("userId") String userId);

    /**
     * 将购物车缓存到redis中
     * @param cartDto
     */
    @RequestMapping("/redis/cart/insertCart")
    void insertCart(@RequestBody CartDto cartDto);

    /**
     * 根据用户ID查询用户购物车
     * @param userId
     * @return
     */
    @RequestMapping("/redis/cart/selectCartByUserId")
    CartDto selectCartByUserId(@RequestParam Long userId);
}
